#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<stropts.h>
#include<linux/fb.h>

#define LCD "/dev/fb0"

int open_lcd(){
    int lcdfd = open(LCD,O_RDWR);
    if(-1 == lcdfd){
        perror("open err");
        return -1;
    }
    printf("open success\n");

    struct fb_var_screeninfo info;
    int ret = ioctl(lcdfd,FBIOGET_VSCREENINFO,&info);
    printf("可见区的高度:x=%d\n",info.xres);
    printf("可见区的宽度:y=%d\n",info.yres);
    printf("虚拟区的高度:x=%d\n",info.xres_virtual);
    printf("虚拟区的宽度:y=%d\n",info.yres_virtual);
    printf("横向偏移量:x_offset=%d\n",info.xoffset);
    printf("纵向偏移量:y_offset=%d\n",info.yoffset);
    printf("像素位数:bit_per_pixel=%d\n",info.bits_per_pixel);
    
    printf("红色显示:偏移量=%d 位域宽度=%d\n",info.red.offset,info.red.length);
    
    printf("绿色显示:偏移量=%d 位域宽度=%d\n",info.green.offset,info.green.length);

    printf("蓝色显示:偏移量=%d 位域宽度=%d\n",info.blue.offset,info.blue.length);




    return lcdfd;
}

int main(int argc,char const argv[]){

    open_lcd();
    return 0;

}